package com.spi.soconversion.base.definition;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.spi.soconversion.util.SOCConstants;
import com.spi.soconversion.util.XMLTagConstants;

public class SOCOrderLineCharges {
	
	private List<SOCOrderLineCharge> orderLineChargeList = new ArrayList<SOCOrderLineCharge>();
	
	public boolean addOrderLineCharge(SOCOrderLineCharge olc){
		boolean status = false;
		if(!orderLineChargeList.contains(olc)) {
			status = orderLineChargeList.add(olc);
		}
		
		return status;
	}
	
	public boolean removeOrderLineCharge(SOCOrderLineCharge olc){
		boolean status = false;
		status = orderLineChargeList.remove(olc);
				
		return status;
	}

	public List<SOCOrderLineCharge> getOrderLineChargeList(){
		return orderLineChargeList;		
	}
	
	@Override
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		
		if(orderLineChargeList!=null && orderLineChargeList.size()>0)
		{
			sb.append(XMLTagConstants.START_TAG_LINE_CHARGES);
			Iterator<SOCOrderLineCharge> iter=orderLineChargeList.iterator();
    		while(iter.hasNext())
	    	{
    			sb.append(SOCConstants.NEW_LINE);
    			sb.append(iter.next().toString());  
			}
    		sb.append(SOCConstants.NEW_LINE);
    		sb.append(XMLTagConstants.END_TAG_LINE_CHARGES);
    		
		}
		
		return sb.toString();
	}

}
